<?php

namespace Kunfeng\Dify\Model\Datasets;

/**
 * 文档列表响应模型
 */
class DocumentListResponse
{
    private $data;
    private $total;
    private $page;
    private $limit;

    public function __construct(array $data)
    {
        $this->data = array_map(function($item) {
            return Document::fromArray($item);
        }, $data['data'] ?? []);
        $this->total = $data['total'] ?? 0;
        $this->page = $data['page'] ?? 1;
        $this->limit = $data['limit'] ?? 20;
    }

    /**
     * 从数组创建
     */
    public static function fromArray(array $data): self
    {
        return new self($data);
    }

    // Getters
    public function getData(): array
    {
        return $this->data;
    }

    public function getTotal(): int
    {
        return $this->total;
    }

    public function getPage(): int
    {
        return $this->page;
    }

    public function getLimit(): int
    {
        return $this->limit;
    }
}
